<?phprequire_once('../configs/common.php'); require_once(MODELS_DIR."Validator.class.php");require_once(CONFIGS_DIR."db_connect.php");require_once(MODELS_DIR.'Auth.class.php');if ($_POST['action']=="login"){	 $response=array();	 $login_data=safe_var_Array(json_decode($_POST['data']), true);	 	 if (!Validator::valid_email($login_data['email']))	 {		 $response['status']='Email has not correct format!';	 }	 else	 {		 if (!Auth::isLogged())		 {				 if (Auth::login($login_data['email'],$login_data['password']))			 {				 $response['status']='ok';				 $response['http_referer']=$_SERVER['HTTP_REFERER'];			 }			 else			 {				 $response['status']='not auth'; 			 }		 }		 else		 {			 $response['status']='User already authorized';		 }	 }	 header('Content-Type: application/json');	 echo json_encode($response);}